﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace EmoryResidencyReviewer.Common
{
	public static class Extenders
	{
		#region Session Extenders
		/// <summary>
		/// This extension method enables Session.GetVariables() functionality which 
		/// provides strongly-typed, intellisence-enabled access to session variables.
		/// </summary>
		public static SessionVariables GetVariables(this System.Web.SessionState.HttpSessionState s)
		{
			const string SettingName = "SessionVariablesClass";

			if (HttpContext.Current.Session[SettingName] == null)
				HttpContext.Current.Session[SettingName] = new SessionVariables();

			return (SessionVariables)HttpContext.Current.Session[SettingName];
		}
		#endregion

		//#region Application Extenders
		///// <summary>
		///// This extension method enables Application.GetVariables() functionality which 
		///// provides strongly-typed, intellisence-enabled access to application variables.
		///// </summary>
		//public static ApplicationVariables GetVariables(this System.Web.HttpApplicationState s)
		//{
		//  //const string SettingName = "ApplicationVariablesClass";

		//  //if (HttpContext.Current.Application[SettingName] == null)
		//  //    HttpContext.Current.Application[SettingName] = new ApplicationVariables();

		//  //return (ApplicationVariables)HttpContext.Current.Application[SettingName];
		//  return GetVariables(s, HttpContext.Current);
		//}

		//public static ApplicationVariables GetVariables(this System.Web.HttpApplicationState s, System.Web.HttpContext CurrentContext)
		//{
		//  const string SettingName = "ApplicationVariablesClass";
		//  try
		//  {
		//    if (CurrentContext.Application[SettingName] == null)
		//      CurrentContext.Application[SettingName] = new ApplicationVariables();
		//    return (ApplicationVariables)CurrentContext.Application[SettingName];
		//  }

		//  catch
		//  { }
		//  return null;

		//}
		//#endregion
	}
}